
# 创建包含指定个数元素的数组
events = [0] * 1000
maxBucketList = 0

with open("BucketList.in", "r") as ifs:

  cows = int(ifs.readline())
  # cows -> 字符串
  print(type(cows))

  for line in ifs:
    numbers = line.split()
    si = int(numbers[0])
    ti = int(numbers[1])
    bi = int(numbers[2])

    events[si] += bi
    events[ti] -= bi

  currBucketList = 0

  for b in events:
    currBucketList += b

    if currBucketList > maxBucketList:
      maxBucketList = currBucketList

print(maxBucketList)
with open("BucketList.out", "w") as ofs:
  ofs.write(str(maxBucketList))
